<?php
namespace app\finance\controller;

use think\Db;
use think\Request;
use Godok\Org\Auth;
use think\Controller;
use think\Config;
class Base extends Controller {

	public function __construct()
	{
		parent:: __construct();
		$this->user = Auth::user();
		$this->uid  = isset($this->user['id'])?$this->user['id']:null;
		
		$groupids = \Godok\Org\Auth::user('groupids');

        //获取用户身份
        $groupids = \Godok\Org\Auth::user('groupids');
        if (empty($groupids)) {
            $this->redirect(url('Login/index'));
        }else{
            $group = Db::name( Config::get('auth.table_group') )->where(['id' => $groupids[0]])->find();
            switch ($group['code']) {
                case 'CW':
					if(request()->module() != 'finance'){
						$this->redirect(url('finance/Index/index'));
					}
					break;
                default:
                	$this->error('对不起！您无权进行该操作',url('Login/index'));
                    break;
            }
        }
	}
}